﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="ListDocumentCheck.aspx.cs" Inherits="lcsign.Web.documentTransfer.ListDocumentCheck" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script type="text/javascript">

        var did = "";
        var uid = "<%=uid%>";
         $(function () {
             InitGird();

         });

         //初始化表格
         function InitGird() {
             $('#tt').datagrid({
                 title: '文档列表', //表格标题
                 url: 'DocOp.ashx', //请求数据的页面
                 idField: 'did', //标识字段,主键
                 iconCls: '', //标题左边的图标
                 width: '100%', //宽度
                 //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                 nowrap: false, //是否换行，True 就会把数据显示在一行里
                 striped: true, //True 奇偶行使用不同背景色
                 collapsible: false, //可折叠
                 sortOrder: 'desc', //排序类型
                 remoteSort: true, //定义是否从服务器给数据排序
                 fitColumns: true,
                 singleSelect: true,
                 method: 'post',
                 columns: [[
                     { field: 'ckb', checkbox: true },
                     { title: '文档名', field: 'dtitle', width: 80, sortable: true },
                     { title: '上传人', field: 'utruename', width: 80 },
                     { title: '上传时间', field: 'ddatetime', width: 150 }
                     ,
                     {
                         title: '操作', field: 'did', width: 80, formatter: function (value, row, index) {
                            
                             //var upfilename = row.upfile.substring(0, row.upfile.indexOf("."));
                             return "&nbsp;<a style='color:red' href='javascript:' "
                                 + "onclick=\"$(this).parent().click();checkDoc('" + row.upfile + "','" + row.dtitle + "'," + row.did + ");return false;\">审核</a>";


                         }
                     }
                 ]],
                 //toolbar: "#tab_toolbar",
                 queryParams: { "action": "querymy" },
                 pagination: false, //是否开启分页
                 //pageNumber: 1, //默认索引页
                 //pageSize: 20, //默认一页数据条数
                 rownumbers: true //行号
             });


         }
        //审核通过
         function ok_click() {
             var documentId = $("#did").val();

             if (documentId != "" && uid != "") {
                 var filename = $("#upfile").val();
                 var url = encodeURI("<%=mHttpUrl %>" + "documentinfo/FileSave.aspx?DocumentID=" + filename);
                 var result = iStylePDF.HttpClient.UpLoadToServer(url);

                 if (result == 200) {

                     $.ajax({
                         url: "DocOp.ashx?id=" + documentId + "&action=check_ok&uid=" + uid,//此处不能有空格“id = " + did”这样写会出错
                         dataType: "text",
                         data: "{}",
                         type: "POST",
                         success: function (result) {
                             if ((result.indexOf("T") == 0)) {
                                 $('#dlg').dialog('close');
                                 $.messager.alert("提示", "操作成功！", "info");
                                 $('#tt').datagrid('reload');

                             } else if (result == "F_DI01") {
                                 $.messager.alert("提示", "提交失败！", "info");
                                 return;

                             }
                         },
                         error: function (x, e) {
                             //alert(x.responseText);

                         }
                     });

                 } else {
                     $.messager.alert("提示", "上传文件失败，返回值为" + result, "info");
                 }

               
             }
         }
        //审核不通过
         function no_click() {
             var documentId = $("#did").val();

             if (documentId != "" && uid != "") {
                 var filename = $("#upfile").val();
                 var url = encodeURI("<%=mHttpUrl %>" + "documentinfo/FileSave.aspx?DocumentID=" + filename);
                 var result = iStylePDF.HttpClient.UpLoadToServer(url);

                 if (result == 200) {

                     $.ajax({
                         url: "DocOp.ashx?id=" + documentId + "&action=check_no&uid=" + uid,//此处不能有空格“id = " + did”这样写会出错
                         dataType: "text",
                         data: "{}",
                         type: "POST",
                         success: function (result) {
                             if ((result.indexOf("T") == 0)) {
                                 $('#dlg').dialog('close');
                                 $.messager.alert("提示", "操作成功！", "info");
                                 $('#tt').datagrid('reload');

                             } else if (result == "F_DI01") {
                                 $.messager.alert("提示", "提交失败！", "info");
                                 return;

                             }
                         },
                         error: function (x, e) {
                             //alert(x.responseText);

                         }
                     });

                 } else {
                     $.messager.alert("提示", "上传文件失败，返回值为" + result, "info");
                 }


             }
         }
        //打开审核
         function checkDoc(upfile,dtitle,did) {
             //清空内容  
             $('#fm').form('clear');        
             $('#dlg').dialog('open').dialog('setTitle', '审核');
             $("#did").val(did);
             $("#dtitle").html(dtitle);//标题
             $("#upfile").val(upfile);
             document.getElementById("test").value = "check";
             var url = encodeURI("<%=mHttpUrl %>" + "documentinfo/FileLoad.aspx?DocumentID=" + upfile);
             iStylePDF.HttpClient.DownLoadToFile(url);
         }
         function reloadgrid() {
             $("#tt").datagrid('reload');
         }
    </script>

     <script type="text/javascript" language="javascript" for="iStylePDF" event="OnApplicationCreate(App)">
         //控件创建完成事件
         //控件使用的语言
         var lcid = App.Options.Lcid;
         //控件是否高亮域
         //App.Options.HighlightField = false;
         //隐藏下侧的导航工具栏
         App.Options.NavBarVisible = false;
         //隐藏左侧的命令工具栏
         App.Options.TabCommandBarVisible = false;
         //是否允许键盘快捷键操作
         App.Options.EnableAccelerator = true;
         //是否允许打开的文档记录历史记录中
         App.Options.HistoryEnabled = false;
         //设置单文档模式
         App.Options.DocumentsLayout = 0;
         //是否显示起始页
         App.Options.StartPageVisible = false;
         //打开文档100%显示
         //App.Options.PageZoomMode = 1;
         //App.Options.UserName = "青岛信元物和供应链有限公司";
         App.Options.UserName = "艾思玳尔测试";


    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="dlg" class="easyui-dialog" style="width: 1000px; height: 500px; padding: 10px 20px"
        data-options="closed:true,buttons:'#dlg-buttons',shadow:false">

        <form id="fm" method="post">

            <div style="position: relative;z-index:99999" class="fitem">
                <label>标题：</label><span id="dtitle" name="dtitle"></span>
            </div>
            <div class="fitem" >
                图片上传方式： 文件--》创建PDF-->从文件                              
                <input name="Test" id="test" type="hidden" />
                <input name="upfile" id="upfile" type="hidden" />
                <input name="did" id="did" type="hidden" />
                <input id="key" name="key" onkeydown="if(event.keyCode==13)reloadgrid()" type="hidden" />
                
            </div>
           
        </form>
         <div style="height:340px; z-index:-1;position: relative;">
                <object id="iStylePDF" width="100%" height="100%" style="z-index:-100;position: relative;" classid="CLSID:7017318C-BC50-4DAF-9E4A-10AC8364C315" codebase="iStylePDF.cab#version=3,0,6,2155">
                    
                </object>
            </div>
    </div>
    <div id="dlg-buttons">
        
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-ok'" onclick="ok_click()">审核通过</a>
        <a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'" onclick="no_click()">审核不通过</a>
    </div>

</asp:Content>
